IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[GetFundIdByFundNumberAndDomainUserId]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.[GetFundIdByFundNumberAndDomainUserId]
END
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/******************************************************************          
* Name:   [GetInfoEdProposalNumberByProtocolNumber]          
* Purpose:  Gets the InfoEd Proposal Number(FolderNumber) by Protocol Number

* PARAMETERS          
* Name					Description               
* -------------      -------------------------------------------          
* @DomainUserId     Domain user Id from fwkDomainUser table (REQUIRED)          
* @FundNumber		Fund Number (REQUIRED)	
*********************************************************************/ 
CREATE PROC [dbo].[GetFundIdByFundNumberAndDomainUserId]
(
	@DomainUserId INT,
	@FundNumber VARCHAR(12)
)
AS 
SET NOCOUNT ON
BEGIN

	SELECT aaf.FundId,urc.AccessLevel--,aaf.FundNumber,aaf.StatusTypeId,
	FROM AgrAgreement_fct aaf (NOLOCK)
		INNER JOIN dbo.UserResourceCache urc (NOLOCK) ON aaf.ResourceId = urc.ResourceId
	WHERE
	urc.FwkDomainUserId = @DomainUserId
	AND
	aaf.FundNumber = @FundNumber

END